package com.huateng.springcloud;


import com.huateng.springcloud.datasource.DataSourceEndpoint;
import com.huateng.springcloud.datasource.HTDataSource;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;


/**
 * @author Evan
 * @create 2021/7/19 17:05
 */
@SpringBootApplication
@EnableDiscoveryClient
public class CommonApplication {

    public static void main(String[] args) throws Exception {
        new SpringApplicationBuilder(CommonApplication.class)
                .web(WebApplicationType.SERVLET).run(args);
    }

    @Bean
    @Primary
    public HTDataSource dataSource(){
        return new HTDataSource();
    }

    //http://localhost:40002/actuator/datasource 获取数据库连接池信息
    @Bean
    public DataSourceEndpoint dataSourceEndpoint(){
        return new DataSourceEndpoint(this.dataSource());
    }

}
